<?php
require_once BACKGROUND_COMMON_ACTION_SERVICE_DIR . '/default.php';

class background_good_category_edit_action_service extends background_default_common_action_service
{
    protected static $_instance;

    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    protected function _current_page_process()
    {                	
        $result = array('status' => 0, 'message' => '', 'data' => array());
        
        $id = init_user_data_key($_GET, 'id', 'int');
         
        $model_background_good_category = wwy_resource_container::get_model_background_good_category();
        	
        $good_category_info = $model_background_good_category->find($id);
        if(empty($good_category_info)){
            $result['status']  = -4;
            $result['message'] = '该分类不存在';
        }else{
            $parent_id = 0;
            $where = array('not_in_ids' => array($id));    //编辑显示时用到
            $order = array('`order` asc');
            $level = 1;
            $all_category_list = $model_background_good_category->get_children_list($parent_id, $level, $where, $order);
             
            self::add_view_data('good_category_info', $good_category_info);
            self::add_view_data('all_category_list', $all_category_list);           
        }         
        
        self::set_view_status($result['status']);
        self::set_view_message($result['message']);
    }
}